/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.com.jvpn.tools.vpnconn;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 *
 * @author Ken
 */
public class PBKTools {

    public synchronized void createPBK() throws IOException {
        FileWriter pbkFile = new FileWriter("rasphone.pbk");
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("cn/com/jvpn/resources/phonebook");
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        try {
            String tempString = null;
            while ((tempString = reader.readLine()) != null) {
                pbkFile.write(tempString + "\r\n");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            reader.close();
            pbkFile.close();
        }
    }

    public synchronized void delPBK() throws IOException {
        File pbkFile = new File("rasphone.pbk");
//        System.out.println(pbkFile.getAbsoluteFile());
        if (pbkFile.exists()) {
            pbkFile.delete();
        } else {
        }
    }
}
